﻿/**************************************************************
 * Copyright Eastmoney Corporation. All rights reserved.
 * 
 * Author: guitao(guitao@eastmoney.com) 
 * Create Date: 2020/6/16 17:18:59
 * Description:
 *          
 * Revision History:
 *      Date         Author               Description
 *              
***************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;

namespace KafkaPush.Sample
{
    public class Sample
    {
        public void Check()
        {
            Dog dog = new Dog();
            Animal animal = dog;

            //error 编译错误
            //Dog dog2 = animal;

            IList<Dog> dogs = new List<Dog>();
            //error 编译错误
            //IList<Animal> animals_2 = dogs;

            IEnumerable<Dog> dogs_2 = dogs;
            IEnumerable<Animal> animals = dogs_2;

            Action<Dog> action_dog = d => d.Run();
            Action<Animal> action_animal = a => a.Eat();
            //error 编译错误。in
            //Action<Animal> action_animal_2 = action_dog;
            Action<Dog> action_dog_2 = action_animal;

            Func<int, Dog> func_dog = a => { return new Dog(); };
            Func<int, Animal> func_animal = a => { return new Animal(); };

            Func<int, Animal> func_animal_2 = func_dog;
            //error 编译错误。out
            //Func<int, Dog> func_dog_2 = func_animal;
        }
    }

    public class Animal
    {
        public void Eat()
        { }
    }

    public class Dog : Animal
    {
        public void Run()
        {
        }
    }
}
